<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <script language="JavaScript" type="text/JavaScript">

        window.onload = function()
        {
            if('${modifyCustomerInfo}' == "true")
            {
                document.getElementById("div2").style.display = 'none';
                window.open ('existingBookings.jsp','_self',false);
                var result = '<%=request.getAttribute("result")%>';
                var cid = '<%=request.getAttribute("cid")%>';
                window.open('toModifyCustInfo.jsp?result='+result+'&cid='+cid, 'success', 'width=800,height=350,status=yes,resizable=yes,scrollbars=yes');
            }
            if('${modifiedCustomer}' == "true")
            {
                document.getElementById("div2").style.display = 'none';
                window.open('displayModifiedCustomer.jsp?personValues='+'<%=request.getAttribute("personValues")%>', 'success', 'width=800,height=350,status=yes,resizable=yes,scrollbars=yes');
            }

            if('${userSession}' ==  "" || '${userSession}' ==  null)
                self.location = "login.jsp";
            

            if(('${cid}' != "" && '${cid}' != null) || ('${error}' != "" && '${error}' != null))
            {
                document.getElementById("div2").style.display = 'block';
            }
            else
                document.getElementById("div2").style.display = 'block';
        }
        
        function isEmpty(str)
        {
            if(str == null || str == "")
                return true;
            else
                return false;
        }
        
        function validateCustomer()
        {
            var cid = document.getElementsByName("cid")[0].value;
            if(isEmpty(cid))alert("Please enter customer Id.");
            else if(cid.length != 9  || (isNaN(cid)))alert("Please enter valid customer id.");
            else document.getElementById("submit").click();
        }
        
    </script>
    <body>
        <form method="post"  action="modifyCustomerInfo">
            <h1>Staff Home</h1>

            <div id="div2">
                <p>Modify Customer Information</p>
                <table cellspacing="10">
                    <tr><td>Enter Customer Id: </td>
                    <td><input type="text" name="cid" size="9" maxlength="9" value="${cid}"/></td><td style="color:red;">${error}</td></tr>
                </table><br>
            <br>
            <input type="hidden" name="modifyCustomer" value="modifyCustomer"/>
            <input type="button" value="Get Info To Modify Customer" onclick="validateCustomer();"/> 
            <input id="submit" type="submit" name="submit" value="submit"/>               
            </div>
            
        </form>
        
    </body>
</html>